/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.swirrel.listener;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import org.swirrel.util.MethodCall;
import org.swirrel.util.SwirrelException;

/**
 *
 * @author Gronau
 */
public class SwirrelItemListener extends AbstractSwirrelListener implements ItemListener {

    private final MethodCall itemStateChangedCall;

    public SwirrelItemListener(MethodCall itemStateChangedCall) {
        this.itemStateChangedCall = itemStateChangedCall;
        if(! checkSignature(itemStateChangedCall, ItemEvent.class)) {
            throw new SwirrelException("Method must have none or one ItemEvent argument");
        }
    }

    public void itemStateChanged(ItemEvent e) {
        call(itemStateChangedCall, e);
    }
}
